package com.example.transitionsdemo

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.RadioGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.transition.TransitionManager
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.mjun.mtransition.MTransitionManager
import com.mjun.mtransition.MTranstionUtil
import com.zhy.adapter.recyclerview.CommonAdapter

class MainActivity_1 : BaseActivity() {


    override val layoutId: Int
        get() = R.layout.activity_main_1

    override fun initView() {

    }

    override fun initData() {

    }

    override fun initListener() {

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val viewGroup = findViewById<ViewGroup>(R.id.transitions_container)
        val btn = findViewById<Button>(R.id.button)
        val text = findViewById<TextView>(R.id.text)

        var visibled = false
        btn.setOnClickListener {
            TransitionManager.beginDelayedTransition(viewGroup)
            visibled = !visibled
            text.visibility = if (visibled) View.VISIBLE else View.GONE
            MTransitionManager.getInstance().createTransition("example").apply {
                fromPage().setContainer(viewGroup) {
                    fromPage().addTransitionView("container", viewGroup)
                }
                bundle.putObject("name", "java")
            }
            val intent = Intent(viewGroup.context, SecondActivity::class.java)
            viewGroup.context.startActivity(intent)
           MTranstionUtil.removeActivityAnimation(this)
        }
    }
}